test: assert the consequence, not the setter round-trip - #1925
Merged
Conversation
A mechanical sweep for "pure echo" tests — set a property, assert the same property, no production call in between — found 15 in the suite. Each one round -trips a generated [ObservableProperty] setter, so the only way it can fail is if the CommunityToolkit source generator breaks. They cannot catch a defect in this codebase, while inflating the test count and the confidence it implies. Triaged one at a time; the split was NOT the ~50% the backlog guessed. REPLACED (4 tests) — the consequence was real and asserted nowhere: * ProcessManager and Uninstaller FilterText. Both have OnFilterTextChanged -> ApplyFilter, which rebuilds the collection the DataGrid binds to; the echo tests never touched it. A filter wired to nothing is a defect this project has already shipped (batch 30, five unreachable Services filters) and the old assertions could not have caught it. Now asserted: the bound list narrows, clearing restores it, PID and description match for processes, package Id matches for apps, and the Uninstaller's AppCount and "(of N total)" summary follow. REPLACED (1 test) — the interesting question was one level up: * FriendlyEventEntry extreme timestamps. Storing MinValue/MaxValue proved a DateTime field holds a DateTime. What matters is what RelativeTime and FullTimestamp DO with them, since RelativeTime subtracts from DateTime.Now: a future stamp yields a NEGATIVE span. Behaviour pinned as-is (MinValue -> em dash, future -> "just now"), plus an assertion that no negative duration can ever reach the user if those branches are reordered. REMOVED (9 tests) — nothing left to assert, and the real behaviour is already covered elsewhere, verified case by case: * Dashboard OsLine/UptimeLine/CpuPercent/RamPercent "_Setter_Works" — notification is what a binding depends on, and Setter_FiresPropertyChanged covers it; the two percentages were missing from it, so they were added (its parameter widened to object) rather than dropped. * Cleanup TempSizeLabel/RecycleBinLabel "_CanBeSetDirectly" — covered by _DefaultIsScanning and PreScan_EventuallyPopulatesLabels. * Cleanup Progress_AcceptsFullRange — the name implied a 0-100 contract nothing enforces (ViewModelBase._progress is unclamped). * Performance SelectedPlan_CanBeChanged — default and notification both covered. * AppPackage Status_Transitions_ArePossible, PingTarget Stats_CanBeUpdated — model echoes with no computed members over them. * DuplicateFile MinSizeKb_CanBeChanged — its real consequence is `minBytes = MinSizeKb * 1024`, which needs a guard the code lacks (a large typed value overflows long and inverts the filter). Tracked separately so this stays behaviour-neutral. Red proof: 6 mutations, all 3 touched source files restored byte-for-byte. Every replacement goes red when its claim is broken — unwiring either filter, breaking the PID or Id match, dropping the summary qualifier, or letting a negative span past the "just now" branch. No production code changed; net -9 [Fact]/[Theory].
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
A mechanical sweep for pure-echo tests — set a property, assert that same property, no production
call in between — found 15 in the suite:
Every one of these exercises the CommunityToolkit
[ObservableProperty]source generator, not thiscodebase. They cannot fail on a real defect, and they inflate the test count and the confidence that
number implies. Backlog item #127.
The backlog guessed ~50% false positives. Triaging each one against current source gave a different
and more useful split.
Replaced — the consequence was real and asserted nowhere (5)
Both
FilterTextproperties are wired (OnFilterTextChanged → ApplyFilter), andApplyFilterrebuilds the collection the DataGrid binds to. The echo tests never looked at it. A filter wired to
nothing is a defect this project has already shipped — batch 30, five unreachable Services filters —
and the old assertion could not have caught it. Now asserted:
ProcessManager…FilterText_NarrowsTheBoundListProcessManager…FilterText_AlsoMatchesPidAndDescriptionAppCount+ the "(of N total)" summary followUninstaller…NarrowsTheListAndCorrectsTheCountAndSummaryUninstaller…FilterText_AlsoMatchesThePackageIdFriendlyEventEntryextreme timestamps — storingMinValue/MaxValueproved aDateTimefieldholds a
DateTime. The reachable question is whatRelativeTimeandFullTimestampdo with them,because
RelativeTimesubtracts fromDateTime.Now, so a future stamp produces a negative span.Behaviour is pinned as-is (MinValue → em dash, future → "just now") plus an assertion that no negative
duration can reach the user if those branches are ever reordered. Deliberately not "fixed": "just now"
for a clock-corrected event is imprecise but harmless, and far better than printing "in -3d".
Removed — nothing left to assert (9), each verified case by case
OsLine/UptimeLine/CpuPercent/RamPercent_Setter_Works— notification is what abinding depends on, and
Setter_FiresPropertyChangedalready covers it. The two percentages weremissing from that theory, so they were added to it (parameter widened to
object) rather thansimply dropped.
TempSizeLabel/RecycleBinLabel_CanBeSetDirectly— covered by_DefaultIsScanningand
PreScan_EventuallyPopulatesLabels.Progress_AcceptsFullRange— the name implied a 0-100 contract nothing enforces(
ViewModelBase._progressis unclamped; the ProgressBar clamps visually).SelectedPlan_CanBeChanged— default and notification both already covered.AppPackage.Status_Transitions_ArePossible,PingTarget.Stats_CanBeUpdated— model echoes withno computed members over them.
DuplicateFile.MinSizeKb_CanBeChanged— its real consequence isminBytes = MinSizeKb * 1024inScanAsync, and asserting that needs a guard the code does not have: a large typed value overflowslongand inverts the filter (asking for "≥ 9 quadrillion KB" returns everything). Trackedseparately so this change stays behaviour-neutral.
Verification
Red proof: 6 mutations, all 3 touched source files restored byte-for-byte. Every replacement goes
red when its claim is broken — which is the whole point, since the tests it replaced could not go red
at all:
ProcessManager.OnFilterTextChanged(the batch-30 defect)Uninstaller.OnFilterTextChangedMatchesPidalways falseIdSummarydrops the "(of N total)" qualifierNo production code changed. All four projects build 0 errors / 0 warnings;
dotnet format --verify-no-changesexit 0; author headers intact on all 9 files; leak scan over all 32terms gives 0 hits. Net -9
[Fact]/[Theory]attributes (14 removed, 5 added) plus 2 new theoryrows, so the CI count should read 4689.
test:— no version bump, no release.